﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.Entity.ModelConfiguration;
using CSP.Model.CSP;
using System.ComponentModel.DataAnnotations;

namespace CSP.DataAccess.Mapping
{
    public class SearchInfoMap : EntityTypeConfiguration<SearchInfo>
    {
        public SearchInfoMap()
        {
            // Primary Key
            this.HasKey(t => new { t.ServiceId, t.LastModified });

            // Properties
            this.Property(t => t.ServiceId)
                .HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);

            this.Property(t => t.LastModified)
                .IsRequired()
                .IsFixedLength()
                .HasMaxLength(8)
                .IsRowVersion();

            // Table & Column Mappings
            this.ToTable("SearchInfo");
            this.Property(t => t.ServiceId).HasColumnName("ServiceId");
            this.Property(t => t.ServiceTypeId).HasColumnName("ServiceTypeId");
            this.Property(t => t.Title).HasColumnName("Title");
            this.Property(t => t.KeyWords).HasColumnName("KeyWords");
            this.Property(t => t.AgeStart).HasColumnName("AgeStart");
            this.Property(t => t.AgeEnd).HasColumnName("AgeEnd");
            this.Property(t => t.Province).HasColumnName("Province");
            this.Property(t => t.County).HasColumnName("County");
            this.Property(t => t.City).HasColumnName("City");
            this.Property(t => t.LastModified).HasColumnName("LastModified");
            this.Property(t => t.OrderId).HasColumnName("OrderId");
        }
    }
}
